package com.cidp.system.service.impl;

import com.cidp.system.dao.IDictParamDao;
import com.cidp.system.model.TdictParam;
import com.cidp.system.service.IDictParamService;
import com.litt.core.exception.BusiException;
import com.litt.core.page.IPageList;
import com.litt.core.page.PagePoParam;
/**
 * <b>标题：</b>字典管理Service实现.
 * 
 * <pre>
 * &lt;b&gt;描述&lt;/b&gt;
 *    字典管理
 * </pre>
 * 
 * @author lijian
 * @since 2008-5-23
 * @version 1.0
 */
public class DictParamServiceImpl implements IDictParamService {
	
	private IDictParamDao dictParamDao;
	
	/**
	 * 读取字典信息
	 * 
	 * @param dictId 字典ID
	 * @return TdictParam对象
	 * @throws BusiException 
	 */
	public TdictParam loadById(Long dictId) throws BusiException{
		if(dictId != null)
			return dictParamDao.loadById(dictId);
		else 
			throw new BusiException("传入参数为空");
	}
	
	/**
	 * 逻辑删除字典信息.
	 * 
	 * @param dictId 字典信息ID
	 * @throws BusiException 
	 */
	public void deleteDictParam(Long dictId) throws BusiException{
		if(dictId != null)
			dictParamDao.deleteDictParam(dictId);
		else 
			throw new BusiException("传入参数为空");
	}
	
	/**
	 * 屏蔽字典信息.
	 * 
	 * @param dictId 字典信息ID
	 * @throws BusiException 
	 */
	public void shieldDictParam(Long dictId) throws BusiException{
		if(dictId != null){
			TdictParam dictParam = dictParamDao.loadById(dictId);
			dictParam.setStatus(new Long(1));
			dictParamDao.updateDictParam(dictParam);
		}
		else 
			throw new BusiException("传入参数为空");
	}
	
	/**
	 * 恢复屏蔽的字典信息.
	 * 
	 * @param dictId 字典信息ID
	 * @throws BusiException 
	 */
	public void unshieldDictParam(Long dictId) throws BusiException{
		if(dictId != null){
			TdictParam dictParam = dictParamDao.loadById(dictId);
			dictParam.setStatus(new Long(0));
			dictParamDao.updateDictParam(dictParam);
		}
		else 
			throw new BusiException("传入参数为空");
	}
	

	/**
	 * 恢复逻辑删除的字典信息.
	 * 
	 * @param dictId 字典信息ID
	 * @throws BusiException 
	 */
	public void resumeDictParam(Long dictId) throws BusiException{
		if(dictId != null)
			dictParamDao.resumeDictParam(dictId);
		else 
			throw new BusiException("传入参数为空");
	}

	/**
	 * 保存字典信息.
	 * 
	 * @param dictParam 字典信息对象
	 * @return 主键
	 * 
	 */
	public Long saveDictParam(TdictParam dictParam){
		return dictParamDao.saveDictParam(dictParam);
	}

	/**
	 * 更新字典信息.
	 * 
	 * @param dictParam 字典信息对象
	 */
	public void updateDictParam(TdictParam dictParam){
		dictParamDao.updateDictParam(dictParam);
	}
	
	/**
	 * 分页查询参数字典信息.
	 * 
	 * @param pagePoParam 查询参数
	 * @return IPageList IPageList对象
	 * @throws BusiException 
	 */
	public IPageList listByPage(PagePoParam pagePoParam) throws BusiException {
		if(pagePoParam != null)
			return dictParamDao.listByPage(pagePoParam);
		else
			throw new BusiException("传入参数为空");
	}

	
	public void setDictParamDao(IDictParamDao dictParamDao) {
		this.dictParamDao = dictParamDao;
	}
}
